<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>gpio: xgpio_intr_tapp_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">gpio
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xgpio__intr__tapp__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xgpio_intr_tapp_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains a design example using the GPIO driver (<a class="el" href="struct_x_gpio.html" title="The XGpio driver instance data. ">XGpio</a>) in an interrupt driven mode of operation. </p>
<p>This example does assume that there is an interrupt controller in the hardware system and the GPIO device is connected to the interrupt controller.</p>
<p>This file is used in the Peripheral Tests Application in SDK to include a simplified test for gpio interrupts.</p>
<p>The buttons and LEDs are on 2 separate channels of the GPIO so that interrupts are not caused when the LEDs are turned on and off.</p>
<pre>
 MODIFICATION HISTORY:</pre><pre> Ver   Who  Date         Changes
</p>
<hr/>
<p>
 2.01a sn   05/09/06 Modified to be used by TestAppGen to include test for
                      interrupts.
 3.00a ktn  11/21/09 Updated to use HAL Processor APIs and minor changes
                      as per coding guidelines.
 3.00a sdm  02/16/11 Updated to support ARM Generic Interrupt Controller
 4.1   lks  11/18/15 Updated to use canonical xparameters and
                      clean up of the comments and code for CR 900381
 4.3   ms   01/23/17 Modified xil_printf statement in main function to
                     ensure that "Successfully ran" and "Failed" strings
                     are available in all examples. This is a fix for
                     CR-965028.
 4.10  gm   07/11/23 Added SDT support.
 4.11  gm   12/06/23 Added IER and GIER calls in SDT flow.</pre><pre></pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a11b79a03b5bf53310d0f20adeca131d6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio__intr__tapp__example_8c.html#a11b79a03b5bf53310d0f20adeca131d6">GpioHandler</a> (void *CallbackRef)</td></tr>
<tr class="memdesc:a11b79a03b5bf53310d0f20adeca131d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">This is the interrupt handler routine for the GPIO for this example.  <a href="#a11b79a03b5bf53310d0f20adeca131d6">More...</a><br/></td></tr>
<tr class="separator:a11b79a03b5bf53310d0f20adeca131d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a590eda570d4e0b373a68f1911ce58d32"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio__intr__tapp__example_8c.html#a590eda570d4e0b373a68f1911ce58d32">GpioIntrExample</a> (INTC *IntcInstancePtr, <a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, u16 DeviceId, u16 IntrId, u16 IntrMask, u32 *DataRead)</td></tr>
<tr class="memdesc:a590eda570d4e0b373a68f1911ce58d32"><td class="mdescLeft">&#160;</td><td class="mdescRight">This is the entry function from the TestAppGen tool generated application which tests the interrupts when enabled in the GPIO.  <a href="#a590eda570d4e0b373a68f1911ce58d32">More...</a><br/></td></tr>
<tr class="separator:a590eda570d4e0b373a68f1911ce58d32"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a94c5c78b0558a936c75dcbe18492c658"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio__intr__tapp__example_8c.html#a94c5c78b0558a936c75dcbe18492c658">GpioSetupIntrSystem</a> (INTC *IntcInstancePtr, <a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, u16 DeviceId, u16 IntrId, u16 IntrMask)</td></tr>
<tr class="memdesc:a94c5c78b0558a936c75dcbe18492c658"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function performs the GPIO set up for Interrupts.  <a href="#a94c5c78b0558a936c75dcbe18492c658">More...</a><br/></td></tr>
<tr class="separator:a94c5c78b0558a936c75dcbe18492c658"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2316ea8becbdd561d98c80ccab43a984"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio__intr__tapp__example_8c.html#a2316ea8becbdd561d98c80ccab43a984">GpioDisableIntr</a> (INTC *IntcInstancePtr, <a class="el" href="struct_x_gpio.html">XGpio</a> *InstancePtr, u16 IntrId, u16 IntrMask)</td></tr>
<tr class="memdesc:a2316ea8becbdd561d98c80ccab43a984"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function disables the interrupts for the GPIO.  <a href="#a2316ea8becbdd561d98c80ccab43a984">More...</a><br/></td></tr>
<tr class="separator:a2316ea8becbdd561d98c80ccab43a984"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xgpio__intr__tapp__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is the main function of the GPIO example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a2316ea8becbdd561d98c80ccab43a984"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void GpioDisableIntr </td>
          <td>(</td>
          <td class="paramtype">INTC *&#160;</td>
          <td class="paramname"><em>IntcInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrMask</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function disables the interrupts for the GPIO. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">IntcInstancePtr</td><td>is a pointer to the Interrupt Controller driver Instance </td></tr>
    <tr><td class="paramname">InstancePtr</td><td>is a pointer to the GPIO driver Instance </td></tr>
    <tr><td class="paramname">IntrId</td><td>is XPAR_&lt;INTC_instance&gt;_&lt;GPIO_instance&gt;_VEC value from xparameters.h </td></tr>
    <tr><td class="paramname">IntrMask</td><td>is the GPIO channel mask</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="group__gpio__api.html#ga21c295f935fdc4e37c9f958b3652fbf6">XGpio_InterruptDisable()</a>.</p>

<p>Referenced by <a class="el" href="xgpio__intr__tapp__example_8c.html#a590eda570d4e0b373a68f1911ce58d32">GpioIntrExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a11b79a03b5bf53310d0f20adeca131d6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void GpioHandler </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>CallbackRef</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This is the interrupt handler routine for the GPIO for this example. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">CallbackRef</td><td>is the Callback reference for the handler.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="group__gpio__api.html#ga5138b55159f8b2387f5cf16079b40bbe">XGpio_InterruptClear()</a>.</p>

<p>Referenced by <a class="el" href="xgpio__intr__tapp__example_8c.html#a590eda570d4e0b373a68f1911ce58d32">GpioIntrExample()</a>, and <a class="el" href="xgpio__intr__tapp__example_8c.html#a94c5c78b0558a936c75dcbe18492c658">GpioSetupIntrSystem()</a>.</p>

</div>
</div>
<a class="anchor" id="a590eda570d4e0b373a68f1911ce58d32"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int GpioIntrExample </td>
          <td>(</td>
          <td class="paramtype">INTC *&#160;</td>
          <td class="paramname"><em>IntcInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>DeviceId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32 *&#160;</td>
          <td class="paramname"><em>DataRead</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This is the entry function from the TestAppGen tool generated application which tests the interrupts when enabled in the GPIO. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">IntcInstancePtr</td><td>is a reference to the Interrupt Controller driver Instance </td></tr>
    <tr><td class="paramname">InstancePtr</td><td>is a reference to the GPIO driver Instance </td></tr>
    <tr><td class="paramname">DeviceId</td><td>is the XPAR_&lt;GPIO_instance&gt;_DEVICE_ID value from xparameters.h </td></tr>
    <tr><td class="paramname">IntrId</td><td>is XPAR_&lt;INTC_instance&gt;_&lt;GPIO_instance&gt;_IP2INTC_IRPT_INTR value from xparameters.h </td></tr>
    <tr><td class="paramname">IntrMask</td><td>is the GPIO channel mask </td></tr>
    <tr><td class="paramname">DataRead</td><td>is the pointer where the data read from GPIO Input is returned</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if the Test is successful</li>
<li>XST_FAILURE if the test is not successful</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="xgpio__intr__tapp__example_8c.html#a2316ea8becbdd561d98c80ccab43a984">GpioDisableIntr()</a>, <a class="el" href="xgpio__intr__tapp__example_8c.html#a11b79a03b5bf53310d0f20adeca131d6">GpioHandler()</a>, <a class="el" href="xgpio__intr__tapp__example_8c.html#a94c5c78b0558a936c75dcbe18492c658">GpioSetupIntrSystem()</a>, <a class="el" href="group__gpio__api.html#ga080482882d1f60cbd84b8e4ea856560c">XGpio_Initialize()</a>, <a class="el" href="group__gpio__api.html#gaa5b62394f65ecbb6566d91412616509c">XGpio_InterruptEnable()</a>, <a class="el" href="group__gpio__api.html#ga116bf1509220aa688f76f80501eb0d9e">XGpio_InterruptGlobalEnable()</a>, and <a class="el" href="group__gpio__api.html#ga3b208ffd7b19c2176d459223bc63ea14">XGpio_LookupConfig()</a>.</p>

<p>Referenced by <a class="el" href="xgpio__intr__tapp__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a94c5c78b0558a936c75dcbe18492c658"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int GpioSetupIntrSystem </td>
          <td>(</td>
          <td class="paramtype">INTC *&#160;</td>
          <td class="paramname"><em>IntcInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_x_gpio.html">XGpio</a> *&#160;</td>
          <td class="paramname"><em>InstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>DeviceId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>IntrMask</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function performs the GPIO set up for Interrupts. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">IntcInstancePtr</td><td>is a reference to the Interrupt Controller driver Instance </td></tr>
    <tr><td class="paramname">InstancePtr</td><td>is a reference to the GPIO driver Instance </td></tr>
    <tr><td class="paramname">DeviceId</td><td>is the XPAR_&lt;GPIO_instance&gt;_DEVICE_ID value from xparameters.h </td></tr>
    <tr><td class="paramname">IntrId</td><td>is XPAR_&lt;INTC_instance&gt;_&lt;GPIO_instance&gt;_IP2INTC_IRPT_INTR value from xparameters.h </td></tr>
    <tr><td class="paramname">IntrMask</td><td>is the GPIO channel mask</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if the Test is successful, otherwise XST_FAILURE</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="xgpio__intr__tapp__example_8c.html#a11b79a03b5bf53310d0f20adeca131d6">GpioHandler()</a>, <a class="el" href="group__gpio__api.html#gaa5b62394f65ecbb6566d91412616509c">XGpio_InterruptEnable()</a>, and <a class="el" href="group__gpio__api.html#ga116bf1509220aa688f76f80501eb0d9e">XGpio_InterruptGlobalEnable()</a>.</p>

<p>Referenced by <a class="el" href="xgpio__intr__tapp__example_8c.html#a590eda570d4e0b373a68f1911ce58d32">GpioIntrExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function is the main function of the GPIO example. </p>
<p>It is responsible for initializing the GPIO device, setting up interrupts and providing a foreground loop such that interrupt can occur in the background.</p>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS to indicate success.</li>
<li>XST_FAILURE to indicate failure.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="xgpio__intr__tapp__example_8c.html#a590eda570d4e0b373a68f1911ce58d32">GpioIntrExample()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
